/* @(#)GSLoginAction.java    
*
* Project: BUS
*
* Modify Information:
* =============================================================================
*   Author       Date       Description
*   ------------ ---------- ---------------------------------------------------
*   Simonyi Peng 2006-2-16    建立
*
* Copyright Notice:
* =============================================================================
*    Copyright (c) 2001-2006 Beijing HiTRUST Technology Co., Ltd. 1808 Room, 
*        Science & Technology Building, No. 9 South Street, Zhong Guan Cun, 
*        Haidian District, Beijing ,100081, China All rights reserved.
*
*    This software is the confidential and proprietary information of
*        Beijing HiTRUST Technology Co., Ltd. ("Confidential Information").
*        You shall not disclose such Confidential Information and shall use it
*        only in accordance with the terms of the license agreement you entered
*        into with HiTRUST.
*
* Warning:
* =============================================================================
* 
*/
package com.hitrust.gs.action;

import java.util.ArrayList;

import system.LoginContext;

import com.hitrust.gs.bean.GSOperatorBean;
import com.hitrust.gs.business.GSOrgProcessor;
import com.hitrust.gs.business.GSOrderProcesser;
import com.hitrust.gs.business.GSUniteGwProcessor;
import com.hitrust.gs.form.GSOrderAdvicesForm;
import com.hitrust.gs.lib.GSBaseConstants;
import com.hitrust.gs.lib.GSLogWriter;
import com.hitrust.gs.service.GSBaseAction;
import com.hitrust.gs.service.GSBaseForm;
import com.hitrust.gs.util.exception.GSException;


public class GSOrderReviewAction extends GSBaseAction {
	public String execute(GSBaseForm aForm) throws Exception {
	    
	    LoginContext operatorBean = (LoginContext)aForm.getSession().getAttribute(GSBaseConstants.LOGIN);
        GSOrgProcessor orgproc = new GSOrgProcessor ();
        GSOrderProcesser ordproc = new GSOrderProcesser();
        GSOrderAdvicesForm tForm = (GSOrderAdvicesForm)aForm;
        String[] indexs = tForm.getIndexs();
        String isConfirmOrReject = aForm.getRequest().getParameter("confirmorreject");
        boolean isConfirmOrRejectBoolean = false;
        boolean isSubmit = false;
        if("T".equals(isConfirmOrReject)){
            isConfirmOrRejectBoolean = true;
        }
        if("TT".equals(isConfirmOrReject)){
            isConfirmOrRejectBoolean = true;
            isSubmit = true;
        }
        if("F".equals(isConfirmOrReject)){
            isConfirmOrRejectBoolean = false;
        }
        
        String msg = tForm.getAuditcontent();
        try{
            ordproc.auditOrder(indexs,operatorBean.getLoginUserId(),1,isConfirmOrRejectBoolean,isSubmit,msg);     
            //返回到qryaction时，给出是否重新查询的指示
	        aForm.getRequest().setAttribute("ISQUERYCONDITIONEXIST","T");
	        if("T".equals(isConfirmOrReject)){
	            aForm.getRequest().setAttribute("SUCCESSMSG","申购单复审通过执行成功");
	        }
	        if("F".equals(isConfirmOrReject)){
	            aForm.getRequest().setAttribute("SUCCESSMSG","申购单复审不通过执行成功");
	        }
	        if(isSubmit){
	            aForm.getRequest().setAttribute("SUCCESSMSG","申购单提交成功");
	        }
            //查询当前操作员所能操作的订货单位和地址
            GSUniteGwProcessor process = new GSUniteGwProcessor();
            ArrayList array = process.getWareHouseLevelName(operatorBean.getLoginUserId(), operatorBean.getLoginUserId());
            aForm.getRequest().setAttribute("organdaddr",array);
	        return GSBaseConstants.FORWARD_SUCCESS;
        }catch(GSException e){
            GSLogWriter.error(this,e.toString());
            aForm.getRequest().setAttribute("action","A100901.do");
            throw e;
        }
        
	}
}
